package com.guqj.thread.concurrent;

import java.util.concurrent.locks.LockSupport;

public class LockSupportTest {

	private static Thread mainThread;

	public static void main(String[] args) {
		LockSupportTest ls = new LockSupportTest();
		Worker worker = ls.new Worker("Worker Thread");
		mainThread = Thread.currentThread();
		worker.start();

		System.out.println("mainThread block...");
		LockSupport.park(mainThread);

		System.out.println("mainThread continue...");
	}

	class Worker extends Thread {

		public Worker(String name) {
			super(name);
		}

		@Override
		public void run() {
			System.out.println(Thread.currentThread().getName() + " wakup others");
			// 唤醒mainThread线程
			LockSupport.unpark(mainThread);
		}
	}
}
